package com.example.shoppingdemo.Fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.IdRes;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.shoppingdemo.R;
import com.example.shoppingdemo.nslcommodity.ReturnsActivity;
import com.example.shoppingdemo.nslcommodity.WeOrderForm;

public class MyFragment extends Fragment {
    ImageView imageView1,imageView2,imageView3,imageView4;
    TextView textView;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_my, container, false);
    }
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        textView=findViewById(R.id.text_wodedingdan);
        imageView1=findViewById(R.id.image_daifukuan);
        imageView2=findViewById(R.id.image_daifahuo);
        imageView3=findViewById(R.id.image_daishouhuo);
        imageView4=findViewById(R.id.image_daipingjia);
        LinearLayout layout=findViewById(R.id.linear_returns);
        layout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(requireActivity(), ReturnsActivity.class);
                startActivity(intent);
            }
        });
        textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(requireActivity(), WeOrderForm.class);
                intent.putExtra("id",0);
                startActivity(intent);
            }
        });
        imageView1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(requireActivity(), WeOrderForm.class);
                intent.putExtra("id",1);
                startActivity(intent);
            }
        });
        imageView2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(requireActivity(), WeOrderForm.class);
                intent.putExtra("id",2);
                startActivity(intent);
            }
        });
        imageView3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(requireActivity(), WeOrderForm.class);
                intent.putExtra("id",3);
                startActivity(intent);
            }
        });
        imageView4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(requireActivity(), WeOrderForm.class);
                intent.putExtra("id",4);
                startActivity(intent);
            }
        });
    }
    private <T extends View>T findViewById(@IdRes int resId)
    {
        return getView().findViewById(resId);
    }
}